Skip to content

Feat/block replay time#7205

Open
rob-stacks wants to merge 3 commits into
stacks-network:developfrom
rob-stacks:feat/block_replay_time
Open

Feat/block replay time#7205
rob-stacks wants to merge 3 commits into
stacks-network:developfrom
rob-stacks:feat/block_replay_time

Conversation

@rob-stacks
Copy link
Copy Markdown
Contributor

Description

This simple patch adds a new information to every transaction in the blockreplay/simulate api: execution_time_millis

It is the amount of wall-clock milliseconds required for executing the transaction. It is a simple fallback for those platform
without hardware profiler support.

Note: the patch fixes a bunch of error in the openapi schema

Applicable issues

  • fixes #

Additional info (benefits, drawbacks, caveats)

Checklist

  • Test coverage for new or modified code paths
  • For new Clarity features or consensus changes, add property tests (see docs/property-testing.md)
  • Changelog fragment(s) or "no changelog" label added (see changelog.d/README.md)
  • Required documentation changes (e.g., rpc/openapi.yaml for RPC endpoints, event-dispatcher.md for new events)
  • New clarity functions have corresponding PR in clarity-benchmarking repo

cpu_instructions: profiler_result.cpu_instructions,
cpu_cycles: profiler_result.cpu_cycles,
cpu_ref_cycles: profiler_result.cpu_ref_cycles,
execution_time_millis: execution_duration.as_millis() as u64,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could be worth it to use nanos resolutions instead? I know this is a raw profiling, but just to avoid 0 in case a tx takes less then 1ms.

let err = match tx_result {
TransactionResult::Success(tx_result) => {
txs_receipts.push((tx_result.receipt, profiler_result));
txs_receipts.push((tx_result.receipt, start.elapsed(), profiler_result));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

computing execution_time_millis sounds like a profiler feature. Why not assigning this responsibility to BlockReplayProfiler to centralize all this kind of data collection? It could be available for both linux and not linux build.

Comment on lines 447 to +450
cpu_instructions: profiler_result.cpu_instructions,
cpu_cycles: profiler_result.cpu_cycles,
cpu_ref_cycles: profiler_result.cpu_ref_cycles,
execution_time_millis: execution_duration.as_millis() as u64,
Copy link
Copy Markdown
Contributor

@federico-stacks federico-stacks May 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest organizing the response under a profiler field, aggregating all the current profiling-related fields beneath it. This would allow us to simply mark the parent field as nullable, while also making the structure cleaner, easier to evolve and piloted by the RPC request profiler parameter.

Additionally, this approach would integrate nicely with the refactoring proposed in #7205 (comment).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants